/**
 * <p>Copyright (c) 2011 深圳市鹏途信息技术有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 *
 * <p>项目名称 ： 	东莞交通工程质量监督综合业务系统        </p>
 * <p>创建者   :	libitum
 *
 * <p>描   述  :   HistoryAction.java for com.pengtu.web.business.history    </p>
 *
 * <p>最后修改 : $: 2011-7-21-下午06:05:41 v 1.0.0	 libitum   $     </p>
 *
 */

package com.pengtu.web.history;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.springframework.beans.factory.annotation.Autowired;

import com.pengtu.Constants;
import com.pengtu.entity.history.HistoryProject;
import com.pengtu.model.ActivityModel;
import com.pengtu.service.history.HistoryProjectManager;
import com.pengtu.utils.web.ControlHelpUtil;
import com.pengtu.utils.web.Struts2Utils;
import com.pengtu.web.BaseActionSupport;

/**
 * 
 * HistoryAction
 * 
 * 2011-7-21 下午06:05:41
 * 
 * @version 1.0.0
 * 
 */
public class HistoryAction extends BaseActionSupport<HistoryProject> {

	/**
	 * serialVersionUID:TODO
	 * 
	 * @since 1.0.0
	 */

	private static final long serialVersionUID = 1L;

	private String id;
	private HistoryProject entity;
	private String taskId;
	private List<HistoryProject> historys;
	private String key;

	private HistoryProjectManager historyProjectManager;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	public List<HistoryProject> getHistorys() {
		return historys;
	}

	public void setHistorys(List<HistoryProject> historys) {
		this.historys = historys;
	}

	/**
	 * key
	 * 
	 * @return the key
	 * @since 1.0.0
	 */

	public String getKey() {
		return key;
	}

	/**
	 * @param key
	 *            the key to set
	 */
	public void setKey(String key) {
		this.key = key;
	}

	@Autowired
	public void setHistoryProjectManager(
			HistoryProjectManager historyProjectManager) {
		this.historyProjectManager = historyProjectManager;
	}

	public HistoryProject getModel() {

		return entity;
	}

	@Actions({ @Action("/admin/received/history"),
			@Action("/admin/convey/history"),
			@Action("/business/application/history"),
			@Action("/business/acceptance/history"),
			@Action("/business/completion/history"),
			@Action("/business/detection/history"),
			@Action("/business/labs/history"),
			@Action("/quality/plan/history"),
			@Action("/quality/check/history"),
			@Action("/business/middledetect/history"),
			@Action("/business/marine/detection/history"),
			@Action("/business/marine/check/history"),
			@Action("/cost/budget/history"),
			@Action("/cost/limited/history"),
			@Action("/cost/modify/history"),
			@Action("/cost/completed/history"),
			@Action("/cost/estimate/history"),
			@Action("/cost/drawing/history"),
			@Action("/business/recheck/history"),
			@Action("/human/leave/history")})
	public String list() throws Exception {
		key = (String) ControlHelpUtil.getObjectToRequest("key");
		historys = historyProjectManager.getHistoryProjects(key);
		ActivityModel activityModel = historyProjectManager.getActivityNames(key);
		Struts2Utils.getRequest().setAttribute("ac", activityModel.getActivityCoordinates());
		Struts2Utils.getRequest().setAttribute("maps", activityModel.getAssigns());
		System.out.println("====="+activityModel.getAssigns());
		return "successhistory";
	}

	public String info() throws Exception {
		key = (String) ControlHelpUtil.getObjectToRequest("key");
		historys = historyProjectManager.getHistoryProjects(key);
		return Constants.INFO;
	}

	public String input() throws Exception {

		return null;
	}

	public String save() throws Exception {

		return null;
	}

	public String delete() throws Exception {

		return null;
	}

	protected void prepareModel() throws Exception {
		if (StringUtils.isNotEmpty(id)) {
			entity = historyProjectManager.getHistoryProject(id);
		} else {
			entity = new HistoryProject();
		}
	}

}
